<script>
	var root_path = '<?php echo _SITE_ADMIN_URL_?>';
	var table = 'news';
	var field = 'title';
	
	$(document).ready(function(){
		$('.entity_type').click(function(){
			var type = $(this).val();
			if(type == 1){
				$('#entity_service').show();
				$('#entity_product').hide();
			}else{
				$('#entity_service').hide();
				$('#entity_product').show();
			}
		});
	});
</script>
<div class="container_12"> 
    <div class="module">
        <h2><span><?php echo $_title; ?></span></h2>
        <div class="module-body">
            <div style="margin-top:13px;">
                <?php
                if(isset($errMsg)){?>
                    <span class="notification"><?php echo $_MESSESGE[$errMsg];?></span>
                <?php }?>
			</div>
                        
            <form id="adminForm" name="admin_frm" action="" method="post" enctype="multipart/form-data">
				<p>
					<label>Name</label>
					<div id="availability_info"></div>
					<input type="text" class="input-short check_availability" name="title" value="<?php echo $result['title'];?>" />
					<!--  <span class="notification-input ni-correct">This is correct, thanks!</span> -->
				</p> 
				<p>
					<label>Entity Type</label>
					<input type="radio" class="entity_type" name="entity_type" value="1" <?php echo ($result['entity_type'] == 1)?'checked':''; ?> /> Service News
					<input type="radio" class="entity_type" name="entity_type" value="2" <?php echo ($result['entity_type'] == 2)?'checked':''; ?> /> Product News
				</p> 
				<p style="display:<?php echo $service_display; ?> " id="entity_service">
					<label>Entity</label>
					<select class="input-short" id="service" name="service">
						<option value="">Select Service</option>
						<?php
						foreach($services as $key => $val){
							$selected = ($val['id'] == $sid)?'selected':'';?>
							<option value="<?php echo $val['id']; ?>" <?php echo $selected; ?>><?php echo $val['name']; ?></option>
						<?php } ?>
					</select>
				</p>
				<p style="display:<?php echo $product_display; ?>; " id="entity_product">
					<label>Entity</label>
					<select class="input-short" id="product" name="product">
						<option value="">Select Product</option>
						<?php
						foreach($products as $key => $val){
							$selected = ($val['id'] == $pid)?'selected':'';?>
							<option value="<?php echo $val['id']; ?>" <?php echo $selected; ?>><?php echo $val['name']; ?></option>
						<?php } ?>
					</select>
				</p>
				<p>
					<label>Summary</label>
					<?php $editor->editor('description', $result['summary']) ;?>
				</p>				
				<p>
					<label>Description</label>
					<?php $editor->editor('description', $result['description']) ;?>
				</p>
				<fieldset>
					<input type="hidden" class="input-short" name="id" value="<?php echo $result['id'];?>" />
					<input class="submit-green" type="submit" name="submit" value="Submit" /> 
					<input class="submit-gray" type="button" value="Cancel" onclick="javascript: window.location='<?php echo _SITE_ADMIN_URL_?>'+'content/news_mng.php';" />
				</fieldset>
			</form>
		</div> <!-- End .module-body -->
	</div>  <!-- End .module -->
</div>
<div style="clear:both;"></div>
<script type="text/javascript">
	jQuery.validator.addMethod(
		"selectServiceNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a service."
	);
	
	jQuery.validator.addMethod(
		"selectProductNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a product."
	);
	
	$().ready(function() {
		$("#adminForm").validate({
			rules: {
				title: "required",
				service: {
					selectServiceNone: true
				},
				product: {
					selectProductNone: true
				},
				summary: "required",
				description: "required"
			},
			messages: {
				title: "Please enter news title",
				summary: "Please enter news summary",
				description: "Please enter news description"
			}
		});
	});
</script> 
<script type="text/javascript" src="<?php echo _ADMIN_JS_; ?>check_availability.js"></script>